<%-- 
    Document   : newprovider
    Created on : Jun 6, 2011, 12:35:52 PM
    Author     : javauser
--%>

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@taglib uri="http://struts.apache.org/tags-html" prefix="html"%>
<%@taglib uri="http://struts.apache.org/tags-bean" prefix="bean"%>
<%@taglib uri="http://struts.apache.org/tags-logic" prefix="logic"%>
<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>Adding New Provider</title>
        <script type="text/javascript">
            function MyMethod()
            {
                var check=true;
                var providername;
                var providertype;
                var scriptfile;
                                
                providername=document.getElementById("providername").value;
                if(providername.length==0)
                {
                    document.getElementById("provname").innerHTML="Please,Enter Provider Name";
                    check=false;
                }
                
                providertype=document.getElementById("providertype").value;		
                if(providertype == 0)
                {		
                    document.getElementById("provtype").innerHTML="Please,Select Provider Type";
                    check=false;
                }
                
                scriptfile=document.getElementById("providerscriptpath").value;
                if(scriptfile.length==0 )
                {
                    document.getElementById("provscriptpath").innerHTML="Please,Select Provider Script File";
                    check=false;
                }
                return check;
            }
            
            function showLabel(){
                var OSName="Unknown OS";
                if (navigator.appVersion.indexOf("Win")!=-1) OSName="Windows";
                if (navigator.appVersion.indexOf("Mac")!=-1) OSName="MacOS";
                if (navigator.appVersion.indexOf("X11")!=-1) OSName="UNIX";
                if (navigator.appVersion.indexOf("Linux")!=-1) OSName="Linux";
            
                var providertype=document.getElementById("providertype").value;
                if(providertype=="Book")
                {
                    if(OSName=="Windows")
                        document.getElementById("scriptpath").innerHTML="Your Script File Should be in Directory : D:\\ScriptFiles\\Book";
                    if(OSName=="UNIX")
                        document.getElementById("scriptpath").innerHTML="Your Script File Should be in Directory : /home/userName/ScriptFiles/Book";
                }
                if(providertype=="Media"){
                    if(OSName=="Windows")
                        document.getElementById("scriptpath").innerHTML="Your Script File Should be in Directory : D:\\ScriptFiles\\Media";
                    if(OSName=="UNIX")
                        document.getElementById("scriptpath").innerHTML="Your Script File Should be in Directory : /home/userName/ScriptFiles/Media";
                }
            }
        </script>

    </head>
    <body>
        <table border="0" style="width:100%;" >
            <html:form action="/Next1.do" method="post" onsubmit="return MyMethod();">
                <html:hidden property="index" value="newprovider"/>
                <tr>
                    <td colspan="3" align="center"><h2>Adding New provider (Step One)</h2></td>
                </tr>
                <tr>
                    <td style="width:20%;" align="left"><b>Provider Name</b></td>
                    <td style="width:30%;" align="left"><html:text property="providerName" styleId="providername"></html:text></td>
                    <td style="width:50%;" align="left"><div id="provname"><html:errors property="EmptyProviderName"/><html:errors property="InvalidName"/></div></td>
                </tr>
                <tr>
                    <td style="width:20%;" align="left"><b>Provider Type</b></td>
                    <td  style="width:30%;" align="left">
                        <html:select property="type" size="1" styleId="providertype" onchange="showLabel();">
                            <html:option value="0">Select Type</html:option>
                            <html:option value="Book">Book</html:option>
                            <html:option value="Media">Media</html:option>
                        </html:select></td>
                    <td style="width:50%;" align="left"><div id="provtype" ><html:errors property="EmptyProviderType"/></div></td>
                </tr>
                <tr>
                    <td style="width:20%;" align="left"><b>Script File</b></td>
                    <td style="width:30%;" align="left"><html:file property="scriptPath" styleId="providerscriptpath"></html:file><div id="scriptpath" ></div></td>
                    <td style="width:50%;" align="left"><div id="provscriptpath" ><html:errors property="EmptyScriptPath"/><html:errors property="InvalidScriptFile"/></div></td>
                </tr>
                <tr>
                    <td colspan="3" align="center">
                        <html:submit value="Next"></html:submit>
                        <INPUT TYPE="BUTTON" VALUE="Cancel" ONCLICK="window.location.href='AdminHome.jsp'"/> 
                    </td>  
                </tr>
            </html:form>    
        </table>
    </body>
</html>
